import { createSSRApp } from "vue";
import App from "./App.vue";
import { createPinia } from "pinia";
// 国际化
import { setupRouter } from "./router";
import uviewPlus from "uview-plus";
// #ifdef H5
import eruda from "eruda";
if (location.href.indexOf("eruda") !== -1) {
  eruda.init();
}
// #endif

// uni.setStorageSync("currentUserId", "1862440213582839808");
// uni.setStorageSync("chatDemo_userName", "路人贾");

export function createApp() {
  const app = createSSRApp(App);
  setupRouter(app);
  app.use(uviewPlus);
  app.use(createPinia());
  // 创建 v-scroll-bottom 指令
  app.directive("scroll-bottom", {
    updated(el) {
      // 在元素更新时滚动到底部
      el.scrollTop = el.scrollHeight;
    },
  });
  return {
    app,
  };
}
